//
//  LzwAdressSearchEndVC.m
//  NewHalfsugar
//
//  Created by 刘志武 on 16/1/12.
//  Copyright © 2016年 刘志武. All rights reserved.
//

#import "LzwAdressSearchEndVC.h"
#import "LzwbaseTableView.h"
#import "LzwSeachEndTableCell.h"
#import "LzwAdressSeachWebViewVC.h"

@interface LzwAdressSearchEndVC ()<UITableViewDataSource, UITableViewDelegate>

@property (nonatomic, retain) LzwbaseTableView *myTableView;


@end

@implementation LzwAdressSearchEndVC

-(void)dealloc{
    [_myTableView release];
    [super dealloc];
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor whiteColor];
    
    [self.navigationController.navigationBar setBackgroundImage:[[UIImage imageNamed:@"pink.png"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] forBarMetrics:UIBarMetricsDefault];
    
    
    UIImage * LandRightBar = [UIImage imageNamed:@"return.png"];
    LandRightBar = [LandRightBar imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    
    
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc]initWithImage:LandRightBar style:UIBarButtonItemStylePlain target:self action:@selector(leftButtonAction:)];
    
    
    self.myTableView = [[LzwbaseTableView alloc]initWithFrame:[[UIScreen mainScreen]bounds] style:UITableViewStylePlain];
    
    [self.view addSubview:self.myTableView];
    self.myTableView.delegate = self;
    self.myTableView.dataSource = self;
    
    
    [self.myTableView registerClass:[LzwSeachEndTableCell class] forCellReuseIdentifier:@"cell"];


}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    
    return self.arrayA.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    LzwSeachEndTableCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    
    cell.modleS = [self.arrayA objectAtIndex:indexPath.row];
    
    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    
    LzwAdressSeachWebViewVC *webViewVC = [[LzwAdressSeachWebViewVC alloc]init];
    webViewVC.modleEnd = [self.arrayA objectAtIndex:indexPath.row];
    
    [self.navigationController pushViewController:webViewVC animated:YES];
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 180;
}



- (void)leftButtonAction:(UIBarButtonItem *)bar{

  
    [self dismissViewControllerAnimated:YES completion:^{
        
        
    }];
    
}

-(void)setArrayA:(NSMutableArray *)arrayA{
    
    if (_arrayA != arrayA) {
        [_arrayA release];
        _arrayA = [arrayA retain];
    }
    
    [self.myTableView reloadData];
}



- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
